<?php
/*
  [EWEISHOP] Copyright(C) 2017 Elinkint Inc.
  This is NOT a freeware, use is subject to license terms
   
  PaymentJssdk.php 2018-05-24 18:53 cunx $
   
*/

namespace common\library\wechat\payment;

use common\component\wechat\Wechat;
use common\library\wechat\WechatApi;

/**
 * 提供JSSDK参数
 * Class PaymentJssdk
 * @package common\library\wechat\payment
 * @author cunx
 */
class PaymentJssdk extends WechatApi
{
    public static $apiType = 'payment';
    static $paymentId = 0;
    /**
     * WeixinJSBridge调起支付所需参数
     * @param string $prepayId  预支付prepayId
     * @param bool $asJson      默认按照JSON字符串返回，false则按照数组返回
     * @return array|string
     * @author cunx
     */
    public static function bridgeConfig(string $prepayId, bool $asJson = true){
        $result = self::getInstance()->jssdk->bridgeConfig($prepayId, $asJson);
        return $result;
    }

    /**
     * JSSDK调起支付所需参数
     * @param string $prepayId  预支付prepayId
     * @return array
     * @author cunx
     */
    public static function sdkConfig(string $prepayId){
        $result = self::getInstance()->jssdk->sdkConfig($prepayId);
        return $result;
    }

    /**
     * APP支付调起支付的配置
     * @param $prepayId 预支付prepayId
     * @return array
     * @author cunx
     */
    public static function appConfig($prepayId){
        $result = self::getInstance()->jssdk->appConfig($prepayId);
        return $result;
    }

    /**
     * 生成共享收货地址JS配置
     * @param string $token 微信用户$accessToken
     * @return array|string
     * @author cunx
     */
    public static function shareAddressConfig(string $token){
        $result = self::getInstance()->jssdk->shareAddressConfig($token);
        return $result;
    }


}